package com.dnjn.happiness.emo.api.factory;

import com.dnjn.happiness.common.core.domain.R;
import com.dnjn.happiness.common.core.model.HxBeanSeed;
import com.dnjn.happiness.emo.api.RemoteEmoAvgScoreDailyService;
import com.dnjn.happiness.emo.api.RemoteEmoUserService;
import com.dnjn.happiness.emo.api.domain.EmoAvgScoreDaily;
import com.dnjn.happiness.emo.api.model.EmoUserBean;
import com.dnjn.happiness.emo.api.model.EmoUserVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.util.List;

@Component
public class RemoteEmoAvgScoreDailyFallbackFactory implements FallbackFactory<RemoteEmoAvgScoreDailyService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteEmoAvgScoreDailyFallbackFactory.class);

    @Override
    public RemoteEmoAvgScoreDailyService create(Throwable throwable) {
        log.error("调用emoAvgScoreDaily服务失败：" + throwable.getMessage());
        return new RemoteEmoAvgScoreDailyService() {
            @Override
            public void updateDaily(Long userId, Integer happinessScores, String time, String source) {
                log.error("获取日均失败 ：{}" + throwable.getMessage());
            }

            @Override
            public R<EmoAvgScoreDaily> getEmoAvgScoreDailyByUserIdAndDate(Long userId, LocalDate localDate, String source) {
                return R.fail("获取日均失败 ：{}" + throwable.getMessage());
            }
        };
    }
}
